<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script type="text/javascript">
			/*
			 * 原型
			 * 1.定义:原型是function对象的一个属性，他定义了
			 * 构造函数制造出的对象的公共祖先。通过该构造函数产生的对象，
			 * 可以继承该原型的属性和方法。原型也是对象
			 * 2.利用原型特点和概念，可以提取共有属性
			 * 3.对象如何查看原型 -->隐式属性 __proto__.
			 * 4.对象如何查看对象的构造函数 --> constructor
			 */
			
/*//			Person.prototype-->原型
//			Person.prototype = {}是祖先
			Person.prototype.name = "呵呵";
			function Person(){
			}
			var person = new Person();
			var person1 = new Person();
			console.log(person1.name);*/
			
			/*Person.prototype.LastName = "呵呵";
			Person.prototype.say = function(){
				console.log('hehe');
			}
			function Person(){
			}
			var person = new Person();
			person.say();//hehe*/
			
			/*Person.prototype.LastName = "呵呵";
			Person.prototype.say = function(){
				console.log('hehe');
			}
			function Person(name,age,sex){
				this.name = name;
				this.age = age;
				this.sex = sex;
			}
			var person = new Person("xuming",35,'male');*/
			
			/*function Car(color,owner){
				this.owner = owner;
				this.carName = "BMW";
				this.height = 1400;
				this.lang = 4900;
				this.color = color;
			}
			var car = new Car('red','prof.Li');*/
			
			/*//提取共有属性
			Car.prototype.height = 1400;
			Car.prototype.lang = 4900;
			Car.prototype.carName = "BMW";
			function Car(color,owner){
				this.owner = owner;
				this.carName = "BMW";
				this.height = 1400;
				this.lang = 4900;
				this.color = color;
			}
			var car = new Car('red','prof.Li')*/
			
			/*//增删改查
			Person.prototype.lastName = "deng";
			function Person(name){
				this.name = name;
			}
			var person = new Person("xuming");*/
			
			/*Car.prototype = {
				height = 4900,
				lang = 1400,
				carName = "BMW",
			}
			function Car(){
				
			}*/
			
			
			/*Person.prototype.name = "abc";
			function Person(){
			}
			var obj = {
				name : "sunny"
			}
			var person = new Person();
			console.log(person.name);
			person.__proto__ = obj;
			console.log(person.name);*/
			
			/*Person.prototype.name = "sunny";
			function Person(){
			}
			var person = new Person();
			console.log(person.name);//sunny
			Person.prototype.name = "cherry";
			console.log(person.name);//cherry*/
			
			/*//重点重点==============
			Person.prototype.name = "sunny";
			function Person(){
				//var this = {__proto__ : Person.prototype}
			}
			var person = new Person();
			console.log(person.name);//sunny
			Person.prototype = {
				name : "cherry"
			}
			var person1 = new Person();
			console.log(person.name);//sunny
			console.log(person1.name);//cherry*/
			
/*			var obj = {name : "a"};
			var obj1 = obj;
			obj = {name: "b"};*/
			
			/*Grand.prototype.lastName= "Deng";
			function Grand(){}
			
			var grand = new Grand();
			Father.prototype = grand;
			function Father(){
				this.name = "xuming";
			}
			
			var father = new Father();
			Son.prototype = father;
			function Son(){
				this.hobbit = "smoke";
			}
			var son = new Son();*/
			
			/*Person.prototype = {
				height : 100
			}
			
			function Person(){
				this.height ++;
			}
			
			var person = new Person();
			console.log(person.height);*/
			
			/*var obj = {}//
			var obj1 = new Object();/*/
			
			/*//var obj = Object.create(原型);
			var obj = {name : "sunny",age : 123};
			Object.create(obj);*/
			
			/*Person.prototype.name = "sunny";
			function Person(){
				
			}
			var person = Object.create(Person.prototype);*/
			
			/*
			 * 绝大数对象最终的原型为Object.prototype
			 * 除了:Object.create(null);
			 */
			
//toString()
			
			/*Person.prototype = {
				toString : function(){
					return "heheh";
				}
			}
			function Person(){
			}
			var person = new Person();*/
			
			/*var obj = Object.create(null);
			obj.toString = function(){
				return "hahahh";
			}
			document.write(obj.toString());*/
			
//call/apply  改变this指向
			
			/*function Person(name,age){
				//this== obj
				this.name = name;
				this.age = age;
			}
//			var person = new Person('deng',100);
			var obj = {			
			}
			Person.call(obj,'cheng',300);*/
			
			/*function Person(name,age,sex){
				this.name = name;
				this.age = age;
				this.sex = sex;
			}
			
			function Student(name,age,sex,tel,grand){
//				Person.call(this,name,age,sex);
				Person.apply(this,[name,age,sex]);
				this.tel = tel;
				this.grand = grand;
			}
			var student = new Student('sunny',123,'male',149,2017);*/
			
			/*function Wheel(wheelSize,style){
				this.wheelSize = wheelSize;
				this.style = style;
			}
			
			function Sit(c,sitColor){
				this.c = c;
				this.sitColor = sitColor;
			}
			
			function Model(height,widht,len){
				this.height = height;
				this.width = widht;
				this.len = len;
			}
			
			function Car(wheelSize,style,c,sitColor,height,widht,len){
				Wheel.call(this,wheelSize,style);
				Sit.call(this,c,sitColor);
				Model.call(this,height,widht,len);
			}*/
			
			
			
			
		</script>
		
	</body>
</html>
